#include<stdio.h>

#include<sys/wait.h>
     #include<unistd.h>
     #include<assert.h>
     #include<stdlib.h>
     #include<sys/types.h>
     int main()
     {
       pid_t id=fork();
      //assert(id);
      //子进程的代码执行区
      if(id == 0)
      {
       printf("我是子进程，pid=%d,ppid=%d\n",getpid(),getppid());
     printf("我要执行ls -l 命令\n");
     char* const argv[]={"ls","-l",NULL};
     execl("/usr/bin/ls",argv);                                                                  
      waitpid(id,NULL,0);                                                           
        exit(100);                                                                    
      }                                                                               
                                                                                     
      printf("我是父进程，pid=%d\n",getpid());                                        
     waitpid(id,NULL,WNOHANG);                                                        
      return 0;                                                                       
    }  
